﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Strive.Util.Text;
using Strive.Util.Logging;
using Strive.Core.Validations;
using Strive.Core.Service;
using Strive.Core.Translators;
using Strive.Util.Maths;
using Strive.Reflection;
using Strive.Aspects;
using Strive.Interface.IDataAccessBase.DAO;
using Strive.DataAccess.Base.Model.PageObject;
using Strive.DataAccess.Base.Model.SearcherObject;
using Strive.DataAccess;

using OTA.Notification.Entity.Rule;
using OTA.Notification.Interface.IDAO.Rule;

namespace OTA.Notification.DAO.Rule
{
    public class MsgRuleConfigDetailDao : BaseDAOBean<MsgRuleDetailConfigBean>, IMsgRuleConfigDetailDao
    {

        public MsgRuleConfigDetailDao() : base("notifyDB") { }


        #region IBaseDAOBean<MsgRuleConfigDetailDao>的实现

        /// <summary>
        /// 插入实体
        /// </summary>
        /// <param name="obj">MsgAdapterConfigBean</param>
        /// <returns>影响行数</returns>
        public int DataInsert(MsgRuleDetailConfigBean obj)
        {
            return base.Insert(obj);
        }

        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="obj">MsgAdapterConfigBean</param>
        /// <returns>更新数目</returns>
        public int DataUpdate(MsgRuleDetailConfigBean obj)
        {
            return base.Update(obj);
        }

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="PK">MsgAdapterConfigBean</param>
        /// <returns>删除数目</returns>
        public int DataDelete(MsgRuleDetailConfigBean obj)
        {
            return base.Delete(obj);
        }

        /// <summary>
        /// 根据PK得到实体,
        /// </summary>
        /// <param name="PK">PK</param>
        /// <returns>实体</returns>
        public MsgRuleDetailConfigBean DataSelect(int key)
        {
            return base.GetObject(key);
        }

        /// <summary>
        /// 获得所有实体
        /// </summary>
        /// <returns>实体集合</returns>
        /// <remarks>建议在一万数据以下使用该方法</remarks>
        public IList<MsgRuleDetailConfigBean> SelectAll()
        {
            return base.GetObjectList();
        }

        #endregion


        #region MsgRuleConfigDetailDao扩展

        /// <summary>
        /// 批量删除实体
        /// </summary>
        /// <param name="list">MsgAdapterConfigBean集合</param>
        /// <returns>删除数目</returns>
        public int DataDelete(IList<MsgRuleDetailConfigBean> list)
        {
            return base.Delete(list);
        }

        /// <summary>
        /// 根据主键删除实体
        /// </summary>
        /// <param name="key">主键</param>
        /// <returns>删除数目</returns>
        public int DataDelete(int key)
        {
            return base.Delete(base.Query.Constrain("RuleID").Equal(key));
        }

        /// <summary>
        /// 批量插入实体
        /// </summary>
        /// <param name="obj">MsgAdapterConfigBean集合</param>
        /// <returns>影响行数</returns>
        public int DataInsert(IList<MsgRuleDetailConfigBean> list)
        {
            return base.Insert(list);
        }

        /// <summary>
        /// 批量更新实体
        /// </summary>
        /// <param name="obj">MsgAdapterConfigBean集合</param>
        /// <returns>更新数目</returns>
        public int DataUpdate(IList<MsgRuleDetailConfigBean> list)
        {
            return base.Update(list);
        }

        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageObject">分页对象</param>
        /// <returns>集合</returns>
        /// <remarks>测试百万级数据在10秒内,比MSSQL2005分页性能要高</remarks>
        public PageResult<MsgRuleDetailConfigBean> SelectPageList(BasePageSearch pageObject)
        {
            return base.QueryPageList(pageObject);
        }

        public void DeleteAll(int RuleID, string MsgSendType)
        {
            base.ExceNonQuery("DELETE FROM dbo.MSG_SEND_RULE_CONFIG WHERE RULE_ID =" + RuleID.ToString() + " AND MSG_SEND_TYPE_CODE ='" + MsgSendType + "'");
        }

        #endregion
    }
}
